var express = require('express')
var router = express.Router()
const articleCtrl = require('../controller/article')
const articleValidator = require('../validator/article')
const noAuthisLoginCheck = require('../middleware/noAuthisLoginCheck')

// 添加文章(需要权限)
router.post('/article', articleValidator.addArticle, articleCtrl.addArticle)
// 获取文章列表(不需要权限)
router.get('/articles', articleCtrl.getArticleList)
// 获取随机文章列表
router.get('/articles/random', articleCtrl.getRandomArticleList)
// 获取文章详情(不需要权限)
router.get('/article/:id', articleValidator.getArticle, noAuthisLoginCheck, articleCtrl.getArticleDetail)
// 修改文章(需要权限)
router.put('/article/:id', articleValidator.modifyArticle, articleCtrl.modifyArticle)
// 删除文章(需要权限)
router.delete('/article/:id', articleValidator.deleteArticle, articleCtrl.deleteArticle)
// 获取草稿箱（需要权限）
router.get('/drafts', articleCtrl.getDraftList)
// 获取草稿箱文章详情（需要权限）
router.get('/drafts/:id', articleValidator.getArticle, articleCtrl.getDraftsDetail)

module.exports = router
